package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;
    @Override
    public PageInfo<StudentBean> findAll(int pageNO) {
        PageHelper.startPage(pageNO, IStudentService.PAGESIZE);
        PageInfo<StudentBean> pageInfo = PageInfo.of(mapper.findAll());

        return pageInfo;
    }

    @Override
    public void add(StudentBean student) {
        mapper.add(student);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, int grade) {
        mapper.update(id, grade);
    }

    @Override
    public StudentBean findById(int id) {
        return mapper.findById(id);
    }
}
